﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model CGT.Infrastructure.Entity.GovUser
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="callout callout-info">
                <p>
                    Hi @Model.UserName，欢迎使用排队叫号及服务评价系统.
                </p>
            </div>
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">用户信息</h3>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="" data-original-title="Collapse">
                            <i class="fa fa-minus"></i>
                        </button>
                        <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="" data-original-title="Remove">
                            <i class="fa fa-times"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body table-responsive no-padding">
                    <table class="table table-bordered" id="tblist">
                        <tr>
                            <td>您本次登录时间是：@Model.CurrentLoginTime,IP:@Model.CurrentLoginIP </td>
                        </tr>
                        <tr>
                            <td>您上次登录时间是：@Model.LastLoginTime,IP:@Model.LastLoginIP</td>
                        </tr>
                        <tr>
                            <td>您用户名到期时间 <small class="label label-warning"><i class="fa fa-clock-o"></i> @((Model.UserExpireDate - DateTime.Now).TotalDays.ToString("0"))天</small> </td>
                        </tr>
                        <tr>
                            <td>您密码到期时间 <small class="label label-warning"><i class="fa fa-clock-o"></i> @((Model.PasswordExpireDate - DateTime.Now).TotalDays.ToString("0"))天</small></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">据上次登录间隔时间段内所有失败的情况</h3>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="" data-original-title="Collapse">
                            <i class="fa fa-minus"></i>
                        </button>
                        <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="" data-original-title="Remove">
                            <i class="fa fa-times"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover body-table-head">
                        <colgroup>
                            <col style="width: 150px" />
                            <col style="width: 150px" />
                            <col style="width: 300px" />
                        </colgroup>
                        <thead>
                            <tr>
                                <th class="t_c">
                                    时间
                                </th>
                                <th class="t_c">
                                    来源
                                </th>
                                <th class="t_c">
                                    登录失败原因
                                </th>
                            </tr>
                        </thead>
                        <tbody id="tbodylist"></tbody>
                    </table>
                    <div class="no-data" id="nodata" style="display:none;">
                        <div class="img-box"></div>
                        <div class="text">暂无数据</div>
                    </div>
                </div>
                <div class="box-footer clearfix ">
                    <ul id="pagination" class="pagination pagination-sm no-margin pull-right"></ul>
                </div>
            </div>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script src="@Url.Content("~/lib/art-template/template-web.js")"></script>
    <script id="dataItemTpl" type="text/html">
        {{each data}}
        <tr>
            <td>{{$value.CreatedDate}}</td>
            <td>{{$value.Source}}</td>
            <td>{{$value.Description}}</td>
        </tr>
        {{/each}}
    </script>
    <script type="text/javascript">
        //查询
        initData();
        function initData() {
            //页码
            var pageIndex = 1;
            var url = '@Url.Action("UserFailLog", "Account")'
            //查询列表
            BMCW.ajax({
                url: url,
                type: 'GET',
                dataType: "json",
                data: {
                    rows: 10,
                    page: pageIndex
                },
                success: function (data) {
                    if (data.data.length < 1) {
                        $("#nodata").show();
                        document.getElementById('tbodylist').innerHTML = "";
                        return;
                    }
                    $("#nodata").hide();
                    //模板渲染
                    var html = template('dataItemTpl', data);
                    document.getElementById('tbodylist').innerHTML = html;
                    //分页显示
                    $('#pagination').twbsPagination("destroy");
                    $('#pagination').twbsPagination({
                        totalItems: data.total,
                        visiblePages: 10,
                        pageSize: 10,
                        startPage: parseInt(pageIndex),
                        onPageClick: function (event, page) {
                            pageIndex = page;
                            search();
                        }
                    });
                }
            });
        }

       
    </script>
}

